package com.rx.common;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


/**
 * 
 * @类名: DBUtils
 * @描述: 用于jdbc连接数据库公用类
 * @作者：周帅
 * @日期：2018年6月22日下午2:49:46
 */

public class DBUtils {
	private final static String driver="com.mysql.jdbc.Driver";
	private final static String url="jdbc:mysql://localhost:3306/rx-shop-db";
	private final static String user="root";
	private final static String pwd="";
	static {
		try {
			Class.forName(driver);
		}catch(ClassNotFoundException e) {
			
		}
		
	}
	/**
	 * 获取数据连接对象
	 * 
	 * @return
	 */
	public static Connection getConnection() {
		
		try {
			Connection conn=DriverManager.getConnection(url,user,pwd);
			return conn;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return null;
		
	}
	
	
	
}
